<?php

/*
 * Autheur Miki 2013-17-01
 */

include_once 'config.php';
class User 
{
    //Database connect 
    public function __construct() {
      $db = new DB_Class();
    }
    //Registration process
    public function register_user($name, $username, $password, $email)
    {
        $password = md5($password); ("SELECT id from users WHERE username = '$username' of email = '$email'");
        $sql = mysql_num_rows($sqk);
        if ($no_rows ==0)
        {
            $result = mysql_query ("INSERT INTO users (username, password, name, email) values ('$username', '$password', '$name', '$email')" ) or die (mysql_error());
        }
 else {
            return FALSE;
 }
    }
    //Login process
    public function check_login($emailusername, $password)
    {
        $password = md5($password);
        $result = mysql_query("SELECT id from users WHERE email = '$emailusername' or username ='#emailusername' and password = '$password'");
        $user_data = mysql_fetch_array($result);
        $no_rows = mysql_num_rows($result);
        if ($no_rows == 1)
        {
            $_SESSION['login'] = true;
            $_SESSION['id'] = $user_data['id'];
            return TRUE;
        }
        else
        {
            return FALSE;
        }
    }
     
    //Getting name
    public function check_login($emailusername, $password)
    {
        
    }
    
    
}






?>
